#ifndef NETWORKMANAGER_H
#define NETWORKMANAGER_H

#include <QObject>
#include <QTcpSocket>
#include <QTcpServer>

class NetworkManager : public QObject
{
    Q_OBJECT

public:
    explicit NetworkManager(QObject *parent = nullptr);

    void startServer();
    void connectToServer(const QString &address, quint16 port);

signals:
    void connectionEstablished();
    void dataReceived(const QByteArray &data);
    void errorOccurred(const QString &message);

private slots:
    void onNewConnection();
    void onReadyRead();
    void onDisconnected();

private:
    QTcpServer *server;
    QTcpSocket *socket;
};

#endif // NETWORKMANAGER_H